package com.woorigil.social.controller.admin;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.woorigil.social.Context;
import com.woorigil.social.controller.BaseController;
import com.woorigil.social.domain.searcher.QueryAnalyzer;
import com.woorigil.social.worker.DealDataLoadWorker;

@Controller
@RequestMapping("/admin")
public class DealLoadController extends BaseController {
	@Autowired DealDataLoadWorker worker;
	@Autowired QueryAnalyzer analyer;
	
	@RequestMapping("/deal/load")
	public ModelAndView load(String pw) throws Exception {
		if ("1121".equals(pw)) {
			worker.execute();
		}
		ModelAndView mav = new ModelAndView(getForwordPage("admin/load/success"));
		mav.addObject("totalDealCount", Context.getTotalDealCount());
		mav.addObject("lastUpdatedAt", Context.getLastUpdatedAt());
		return mav;
	}	
}
